<h1><a href="<?php echo $this->url(array("controller" => "advertising", "action" => "index"), "admin", true); ?>"><?php echo $this->translate->_("Advertising"); ?></a> &raquo; <?php
	if($this->customer_type == 0) echo $this->translate->_("List System Default Banners");
	if($this->customer_type == 1) echo $this->translate->_("List Pet Sponsoring Banners");
	if($this->customer_type == 2) echo $this->translate->_("List Classical Advertising Banners");
?></h1>
<div class="rbcontent" id="search_fields">
	<form name="search" action="<?php echo $this->url; ?>" method="get">
	<input type="hidden" name="customer-type" id="customer-type" value="<?php echo $this->customer_type; ?>" />
	<input type="hidden" name="order" id="order" value="<?php echo $this->order; ?>" />
	<input type="hidden" name="dir" id="dir" value="<?php echo $this->dir; ?>" />
	<table>
	<col width="50%" /><col width="50%" />
		<tr>
			<td>
				<div class="filter_item">
					<label><?php echo $this->translate->_("Title"); ?>:</label>
					<input type="text" name="title" value="<?php echo $this->title; ?>" />
				</div>
			</td>
			<td>
				<?php if($this->customer_type != 0): ?>
					<div class="filter_item">
						<label><?php echo $this->translate->_("Customer"); ?>:</label>
						<select name="customer">
							<option></option>
							<?php
								foreach ($this->customers as $customer) {
									$hover = $customer->getId() == $this->customer ? ' selected="selected"' : null;
									echo "<option value='{$customer->getId()}' {$hover}>{$customer->getName()}</option>";
								}
							?>
						</select>
					</div>
				<?php endif; ?>
			</td>
		</tr>
		<tr>
			<td>
				<div class="filter_item">
					<label><?php echo $this->translate->_("Type"); ?>:</label>
					<select name="type">
						<option></option>
						<option value="1" <?php echo (1 == intval($this->type) && strlen($this->type) > 0 ? 'selected="selected"' : ''); ?>>300px * 250px</option>
						<option value="2" <?php echo 2 == intval($this->type) ? 'selected="selected"' : ''; ?>>180px * 150px</option>
					</select>
				</div>
			</td>
			<td>
				<?php if($this->customer_type == 2): ?>
					<div class="filter_item">
						<label><?php echo $this->translate->_("Campaign"); ?>:</label>
						<select name="campaign">
							<option></option>
							<?php
								foreach ($this->campaigns as $campaign) {
									$hover = $campaign->getId() == $this->campaign ? ' selected="selected"' : null;
									echo "<option value='{$campaign->getId()}' {$hover}>{$campaign->getName()}</option>";
								}
							?>
						</select>
					</div>
				<?php endif; ?>
			</td>
		</tr>
		<tr>
			<td>
				<div class="filter_item">
					<label><?php echo $this->translate->_("Active"); ?>:</label>
					<select name="active">
						<option></option>
						<option value="0" <?php echo (0 == intval($this->active) && strlen($this->active) > 0 ? 'selected="selected"' : ''); ?>><?php echo $this->translate->_("Inactive"); ?></option>
						<option value="1" <?php echo 1 == intval($this->active) ? 'selected="selected"' : ''; ?>><?php echo $this->translate->_("Active"); ?></option>
					</select>
				</div>
			</td>
			<td>
				<div class="filter_item">
					<label></label>
					<input type="button" value="<?php echo $this->translate->_("Search"); ?>" data-type="submit" />
					<input type="button" value="<?php echo $this->translate->_("Reset"); ?>" data-type="reset" />
				</div>
			</td>
		</tr>
	</table>
	</form>
</div>
<?php if(count($this->banners) > 0): ?>
	<?php echo $this->paginationControl($this->banners, 'Elastic', 'controls.phtml', array('translate' => $this->translate)); ?>
	<table class="main">
		<thead>
			<tr>
				<th class="<?php $col = "b.file"; echo strcasecmp($this->order, $col) == 0 ? strcasecmp($this->dir, "asc") == 0 ? "sortable selectedUp" : "sortable selectedDown" : "sortable"; ?>" nowrap="nowrap" data-col="<?php echo $col; ?>"><?php echo $this->translate->_("File"); ?></th>
				<th class="<?php $col = "b.title"; echo strcasecmp($this->order, $col) == 0 ? strcasecmp($this->dir, "asc") == 0 ? "sortable selectedUp" : "sortable selectedDown" : "sortable"; ?>" nowrap="nowrap" data-col="<?php echo $col; ?>"><?php echo $this->translate->_("Title"); ?></th>
				<?php if($this->customer_type != 0): ?>
					<th class="<?php $col = "customer_name"; echo strcasecmp($this->order, $col) == 0 ? strcasecmp($this->dir, "asc") == 0 ? "sortable selectedUp" : "sortable selectedDown" : "sortable"; ?>" nowrap="nowrap" data-col="<?php echo $col; ?>"><?php echo $this->translate->_("Customer Name"); ?></th>
				<?php endif; ?>
				<?php if($this->customer_type == 2): ?>
					<th class="<?php $col = "campaign_name"; echo strcasecmp($this->order, $col) == 0 ? strcasecmp($this->dir, "asc") == 0 ? "sortable selectedUp" : "sortable selectedDown" : "sortable"; ?>" nowrap="nowrap" data-col="<?php echo $col; ?>"><?php echo $this->translate->_("Campaign Name"); ?></th>
				<?php endif; ?>
				<th class="<?php $col = "b.width"; echo strcasecmp($this->order, $col) == 0 ? strcasecmp($this->dir, "asc") == 0 ? "sortable selectedUp" : "sortable selectedDown" : "sortable"; ?>" nowrap="nowrap" data-col="<?php echo $col; ?>"><?php echo $this->translate->_("Dimension"); ?></th>
				<th class="<?php $col = "b.type"; echo strcasecmp($this->order, $col) == 0 ? strcasecmp($this->dir, "asc") == 0 ? "sortable selectedUp" : "sortable selectedDown" : "sortable"; ?>" nowrap="nowrap" data-col="<?php echo $col; ?>"><?php echo $this->translate->_("Type"); ?></th>
				<th class="<?php $col = "b.views"; echo strcasecmp($this->order, $col) == 0 ? strcasecmp($this->dir, "asc") == 0 ? "sortable selectedUp" : "sortable selectedDown" : "sortable"; ?>" nowrap="nowrap" data-col="<?php echo $col; ?>"><?php echo $this->translate->_("Views"); ?></th>
				<th class="<?php $col = "b.clicks"; echo strcasecmp($this->order, $col) == 0 ? strcasecmp($this->dir, "asc") == 0 ? "sortable selectedUp" : "sortable selectedDown" : "sortable"; ?>" nowrap="nowrap" data-col="<?php echo $col; ?>"><?php echo $this->translate->_("Clicks"); ?></th>
				<th class="<?php $col = "b.active"; echo strcasecmp($this->order, $col) == 0 ? strcasecmp($this->dir, "asc") == 0 ? "sortable selectedUp" : "sortable selectedDown" : "sortable"; ?>" nowrap="nowrap" data-col="<?php echo $col; ?>"><?php echo $this->translate->_("Status"); ?></th>
				<th class="<?php $col = "b.date_created"; echo strcasecmp($this->order, $col) == 0 ? strcasecmp($this->dir, "asc") == 0 ? "sortable selectedUp" : "sortable selectedDown" : "sortable"; ?>" nowrap="nowrap" data-col="<?php echo $col; ?>"><?php echo $this->translate->_("Date created"); ?></th>
				<th width="1%"></th>
				<th width="1%"></th>
			</tr>
		</thead>
		<tbody>
			<?php foreach($this->banners as $banner): ?>
				<tr>
					<td><a href="/images/userfiles/banners/<?php echo $banner["file"]; ?>" target="_blank"><?php echo $banner["file"]; ?></a></td>
					<td><a href="<?php echo $this->url(array('controller'=>'advertising', 'action'=>'edit-banner', 'customer-type' => $this->customer_type, 'id'=> $banner["id"]), 'admin', true); ?>"><?php echo $banner["title"]; ?></a></td>
					<?php if($this->customer_type != 0): ?>
						<td><a href="<?php echo $this->url(array('controller'=>'advertising', 'action'=>'edit-customer', 'type' => $this->customer_type, 'id'=> $banner["customer_id"]), 'admin', true); ?>"><?php echo $banner["customer_name"]; ?></a></td>
					<?php endif; ?>
					<?php if($this->customer_type == 2): ?>
						<td><a href="<?php echo $this->url(array('controller'=>'advertising', 'action'=>'edit-campaign', 'id'=> $banner["campaign_id"]), 'admin', true); ?>"><?php echo $banner["campaign_name"]; ?></a></td>
					<?php endif; ?>
					<td><?php echo $banner["width"]; ?>px * <?php echo $banner["height"]; ?>px</td>
					<td><?php echo $banner["type"] == 1 ? "300px * 250px" : "180px * 150px"; ?></td>
					<td><?php echo $banner["views"]; ?></td>
					<td><?php echo $banner["clicks"]; ?></td>
					<td><?php echo $banner["active"] == 0 ? $this->translate->_("Inactive") : $this->translate->_("Active"); ?></td>
					<td><?php echo Petolio_Service_Util::formatDate($banner["date_created"], null, true, true); ?></td>
					<td nowrap="nowrap" align="center"><a href="<?php echo $this->url(array('controller'=>'advertising', 'action'=>'edit-banner', 'customer-type' => $this->customer_type, 'id'=> $banner["id"]), 'admin', true); ?>"><?php echo $this->translate->_("Edit"); ?></a></td>
					<td nowrap="nowrap" align="center"><a href="<?php echo $this->url(array('controller'=>'advertising', 'action'=>'delete-banner', 'customer-type' => $this->customer_type, 'id'=> $banner["id"]), 'admin', true); ?>" class="reqconf" title="<?php echo $this->translate->_("Are you sure you want to delete this banner?"); ?>"><?php echo $this->translate->_("Delete"); ?></a></td>
				</tr>
			<?php endforeach; ?>
		</tbody>
	</table>
	<?php echo $this->paginationControl($this->banners, 'Elastic', 'controls.phtml', array('translate' => $this->translate)); ?>
<?php else: ?>
	<div class="error"><?php echo $this->translate->_("No records found."); ?></div>
<?php endif; ?>
<form style="background: #fff;">
	<input type="button" onclick="document.location='<?php echo $this->url(array('action' => 'add-banner')); ?>';" class="submit" value="<?php echo $this->translate->_("Add banner"); ?>" />
	<div class="clear"></div>
</form>
<script type="text/javascript">
	READY(function() {
		Admin.loadJs('filters/base.js');
		Filters.load('/advertising/list-banners');
	});
</script>